package com.cloudwise.gproject.service.impl;

import com.cloudwise.gproject.dao.PotentialCustomerDao;
import com.cloudwise.gproject.entity.PotentialCustomer;
import com.cloudwise.gproject.service.PotentialCustomerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (PotentialCustomer)表服务实现类
 *
 * @author makejava
 * @since 2021-01-11 20:38:27
 */
@Service("potentialCustomerService")
public class PotentialCustomerServiceImpl implements PotentialCustomerService {
    @Resource
    private PotentialCustomerDao potentialCustomerDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PotentialCustomer queryById(Integer id) {
        return this.potentialCustomerDao.queryById(id);
    }

    /**
     * 通过Name查询数据条数
     *
     * @param name
     * @return Integer
     */
    @Override
    public Integer queryByName(String name) {
        Integer integer = this.potentialCustomerDao.queryByName(name);
        return integer;
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<PotentialCustomer> queryAllByLimit(int offset, int limit) {
        return this.potentialCustomerDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param potentialCustomer 实例对象
     * @return 实例对象
     */
    @Override
    public PotentialCustomer insert(PotentialCustomer potentialCustomer) {
        this.potentialCustomerDao.insert(potentialCustomer);
        return potentialCustomer;
    }

    /**
     * 修改数据
     *
     * @param potentialCustomer 实例对象
     * @return 实例对象
     */
    @Override
    public PotentialCustomer update(PotentialCustomer potentialCustomer) {
        this.potentialCustomerDao.update(potentialCustomer);
        return this.queryById(potentialCustomer.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.potentialCustomerDao.deleteById(id) > 0;
    }
}